﻿using System;
using System.Data;

namespace TMDT.BusinessObjects
{
    public class TaiKhoan
    {
        public Guid IDTaiKhoan { get; set; }
        public string TenDangNhap { get; set; }
        public string MatKhau { get; set; }
        public string HoTen { get; set; }
        public string CMND { get; set; }
        public bool GioiTinh { get; set; }
        public DateTime NgaySinh { get; set; }
        public string Email { get; set; }
        public string DienThoai { get; set; }
        public DateTime NgayDangKy { get; set; }
        public DateTime NgayKetThuc { get; set; }
        public Guid IDLoaiTaiKhoan { get; set; }
        public Guid IDTinhThanhPho { get; set; }

        public static TaiKhoan Convert(DataRow row)
        {
            TaiKhoan taiKhoan = new TaiKhoan();
            taiKhoan.IDTaiKhoan = new Guid(row["IDTaiKhoan"].ToString());
            taiKhoan.TenDangNhap = row["TenDangNhap"].ToString();
            taiKhoan.MatKhau = row["MatKhau"].ToString();
            taiKhoan.HoTen = row["HoTen"].ToString();
            taiKhoan.CMND = row["CMND"].ToString();
            taiKhoan.GioiTinh = bool.Parse(row["GioiTinh"].ToString());
            taiKhoan.NgaySinh = DateTime.Parse(row["NgaySinh"].ToString());
            taiKhoan.Email = row["Email"].ToString();
            taiKhoan.DienThoai = row["DienThoai"].ToString();
            taiKhoan.NgayDangKy = DateTime.Parse(row["NgayDangKy"].ToString());
            taiKhoan.NgayKetThuc = DateTime.Parse(row["NgayKetThuc"].ToString());
            taiKhoan.IDLoaiTaiKhoan = new Guid(row["IDLoaiTaiKhoan"].ToString());
            taiKhoan.IDTinhThanhPho = new Guid(row["IDTinhThanhPho"].ToString());

            return taiKhoan;
        }
    }
}
